package com.bruce.controller;

import com.bruce.entity.User;
import com.bruce.service.UserService;
import com.springmvc.anotation.AutoWired;
import com.springmvc.anotation.Controller;
import com.springmvc.anotation.RequestMapping;
import com.springmvc.anotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@Controller
public class UserController {

    @AutoWired
    UserService userService;

    @RequestMapping("/user/query")
    public String findusers(HttpServletRequest request, HttpServletResponse response,@RequestParam("name") String name) throws IOException {
        response.setContentType("text/html;charset=utf-8");
//        List<User> users = userService.findUsers(name);
//        PrintWriter writer = response.getWriter();
//        writer.print("mvc控制器"+name);
        String userMessage = userService.getUserMessage(name);
        request.setAttribute("userMessage",userMessage);
        // 转发
        return "forward:/user.jsp";
    }
}
